<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>2CSS选择器</title>
    <style>
        /*标签名选择器*/
        h4{
            color: red;
        }
        a:link{
            color: gray;
        }
        a:visited{
            color: green;
        }
        a:hover{
            color: red;
        }
        a:active{
            color: orange;
        }
        /*属性选择器*/
        [type="text"]{
            background-color: yellow;
        }
        /*后代选择器*/
        #d1 span{
            background-color: magenta;
        }
        /*子代选择器*/
        #d1>div>span{
            color:yellow;
        }
    </style>
</head>
<body>
    <h4>我是标题</h4>
    <p>我是段落</p>
    <a href="#">我是超链接</a>
    <h4>我是标题</h4>
    <div>我是div1</div>
    <div id="d2">我是div2</div>
    <div>我是div3</div>
    <hr>
    <span class="error">用户名已被占用</span>
    <span class="error">操作失败</span>
    <br>
    <span class="success">有效的手机号</span>
    <span class="success">新增成功</span>
    <hr>
    <a href="https://www.baidu.com">百度一下</a>
    <a href="abc">错误超连接</a>
    <hr>
    <input type="text">
    <input type="password">
    <hr>
    <div id="d1">
        <span>1</span>
        <div>
            <span>2</span>
            <b>测试文字</b>
        </div>
        <span>3</span>
    </div>
</body>
</html>